var sys_context_path = '';
var sys_loading_img = '';

function sys_loading(msg) {
}
function sys_loading_close(msg) {
}
function sys_submiting(msg) {
}
function sys_submiting_close(msg) {
}

function sys_msg(msg, time, title, img) {
}
function sys_warning(content, time, title, img) {
}


function create_url(path) {
	var url = '';
	if (path.indexOf('?') > 0)
		url = sys_context_path + 'mo/' + path + '&time=' + sys_get_time();
	else
		url = sys_context_path + 'mo/' + path + (path.indexOf('.html') > 0 ? '' : '.html') + '?time=' + sys_get_time();
	return url;
}

function sys_get_time() {
	var s_time_pats = new Date();
	var s_parss = s_time_pats.getHours() + s_time_pats.getMinutes()
			+ s_time_pats.getSeconds() + s_time_pats.getMilliseconds();

	return s_parss;
}


function sys_fill_parm(formId) {
	var url = document.location.href;
	var index = url.indexOf('?');
	if (index != -1) {
		url = url.substring(index + 1, url.length);
		var form = $('#' + formId);
		var tag = null;
		var parms = url.split('&');
		var parm = null;
		var page = 1;
		var radList = '';
		for (var i = 0; i < parms.length; i ++) {
			parm = parms[i].split('=');
			if ('page' == parm[0]) {
				page = parm[1];
				continue;
			}
			if (null != parm[1] && '' != parm[1]) {
				tag = form.find('[name="' + parm[0] + '"]');
				
				if (tag.is('input')) {									// 对txt、checkbox、radio三种控件赋值
					if (tag.attr('type') == 'text') {
						tag.val(parm[1]);
					} else {
						index = parm[1].indexOf(',');
						if (index == -1) {								// index == -1 为radio或者是只选择了一个的checkbox
							tag.each(function () {
								if ($(this).val() == parm[1]) 
									$(this).attr('checked', 'checked');
								else
									$(this).removeAttr('checked');
							});
							radList += parm[0] + ',';
						} else {										// 选择了多个选项的checkbox
							var values = parm[1].split(',');
							tag.each(function () {
								for (var x = 0; x < values.length; x ++) {
									if ($(this).val() == values[x]) 
										$(this).attr('checked', 'checked');
								}
							});
						}
					}
				} else if (tag.is('select')) {
					tag.find('option').each(function () {
						if ($(this).val() == parm[1]) 
							$(this).attr('selected', 'selected');
						else 
							$(this).removeAttr('selected');
					});
				}
			}
		}
		
		// 处理未做任何选择的radio组
		var rads = radList.split(',');
		form.find('input[type=radio]').each(function () {
			var i = 0;
			for (; i < rads.length; i ++) {
				if ('' != rads[i] && $(this).attr('name') == rads[i])
					break;
			}
			if (i == rads.length)
				form.find('input[name=' + $(this).attr('name') + ']').removeAttr('checked');
		});
		return page;
	}
}




